package uppacket

import (
	"gitee.com/yanwc/ebike-xiaoan-device/device"
	"gitee.com/yanwc/ebike-xiaoan-device/internal/field"
	"gitee.com/yanwc/ebike-xiaoan-device/internal/frame"

	"github.com/panjf2000/gnet"
)

type WildPacket struct{}

var _ IUpPacket = (*WildPacket)(nil)

func (hbp *WildPacket) Do(frame frame.IFrame, c gnet.Conn) ([]byte, gnet.Action, error) {
	device, ok := device.SessionDevices.GetWithConn(c)
	if !ok {
		return nil, gnet.Close, nil
	}

	device.AcceptCmdResult(field.SerialNumber(frame.GetSN()), frame.Content())
	return nil, gnet.None, nil
}
